package com.tudouji.project.mt.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.mt.domain.MtFoodconsumitem;
import com.tudouji.project.mt.service.IMtFoodconsumitemService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 美团菜品消耗单明细Controller
 * 
 * @author tudouji
 * @date 2023-11-21
 */
@RestController
@RequestMapping("/mt/foodconsumitem")
public class MtFoodconsumitemController extends BaseController
{
    @Autowired
    private IMtFoodconsumitemService mtFoodconsumitemService;

    /**
     * 查询美团菜品消耗单明细列表
     */
    @PreAuthorize("@ss.hasPermi('mt:foodconsumitem:list')")
    @GetMapping("/list")
    public TableDataInfo list(MtFoodconsumitem mtFoodconsumitem)
    {
        startPage();
        List<MtFoodconsumitem> list = mtFoodconsumitemService.selectMtFoodconsumitemList(mtFoodconsumitem);
        return getDataTable(list);
    }

    /**
     * 导出美团菜品消耗单明细列表
     */
    @PreAuthorize("@ss.hasPermi('mt:foodconsumitem:export')")
    @Log(title = "美团菜品消耗单明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MtFoodconsumitem mtFoodconsumitem)
    {
        List<MtFoodconsumitem> list = mtFoodconsumitemService.selectMtFoodconsumitemList(mtFoodconsumitem);
        ExcelUtil<MtFoodconsumitem> util = new ExcelUtil<MtFoodconsumitem>(MtFoodconsumitem.class);
        return util.exportExcel(list, "foodconsumitem");
    }

    /**
     * 获取美团菜品消耗单明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('mt:foodconsumitem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mtFoodconsumitemService.selectMtFoodconsumitemById(id));
    }

    /**
     * 新增美团菜品消耗单明细
     */
    @PreAuthorize("@ss.hasPermi('mt:foodconsumitem:add')")
    @Log(title = "美团菜品消耗单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MtFoodconsumitem mtFoodconsumitem)
    {
        return toAjax(mtFoodconsumitemService.insertMtFoodconsumitem(mtFoodconsumitem));
    }

    /**
     * 修改美团菜品消耗单明细
     */
    @PreAuthorize("@ss.hasPermi('mt:foodconsumitem:edit')")
    @Log(title = "美团菜品消耗单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MtFoodconsumitem mtFoodconsumitem)
    {
        return toAjax(mtFoodconsumitemService.updateMtFoodconsumitem(mtFoodconsumitem));
    }

    /**
     * 删除美团菜品消耗单明细
     */
    @PreAuthorize("@ss.hasPermi('mt:foodconsumitem:remove')")
    @Log(title = "美团菜品消耗单明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mtFoodconsumitemService.deleteMtFoodconsumitemByIds(ids));
    }
}
